package org.csmzxy.class2333;

import java.util.Scanner;

public class Example04 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入第一个正整数：");
        int num1 = scanner.nextInt();
        System.out.println("请输入第二个正整数：");
        int num2 = scanner.nextInt();
        int gcd = findGCD(num1, num2);
        int lcm = findLCM(num1, num2);
        System.out.println("最大公约数是：" + gcd);
        System.out.println("最小公倍数是：" + lcm);
        scanner.close();
    }
    public static int findGCD(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }
    public static int findLCM(int a, int b) {
        return a * (b / findGCD(a, b));
    }
}